<?php
header("content-type:text/html;charset=utf8");
include_once ("Classes/PHPExcel.php");
$excel = PHPExcel_IOFactory::load("test.xls");
$sheet = $excel->getActiveSheet();
$rows = $sheet->getHighestRow();
$cols = $sheet->getHighestColumn();
for ($i=2 ; $i<=$rows;$i++)
{
    for ($j ='A';$j<=$cols;$j++)
    {
        $data[$i-2][]= $sheet->getCell($j.$i)->getValue();

    }
}
$pdo = new PDO("mysql:host=127.0.0.1;dbname=lianxi;charset=utf8",'root','root');
foreach ($data as $k => $v)
{
    $name = $v[0];
    $pwd = $v[1];
    $rpwd = $v[2];
    $shijian = $v[3];
    $sql = "insert into `drzsgc` values ('','$name','$pwd','$rpwd','$shijian')";
     $res = $pdo->exec($sql);
}
if($res)
{
    echo "<script>alert('导入成功');location.href='select.php'</script>";
}

?>
